package com.itheima.网络编程.udp编程;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class UdpServer2 {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket(10000);
        System.out.println("开启服务端:");
        while (true) {
            DatagramPacket dp = new DatagramPacket(new byte[1024 * 1024], 1024 * 1024);
            ds.receive(dp);
            System.out.println("接收端接收的数据是:");
            System.out.println(new String(dp.getData(), 0, dp.getLength()));
        }
    }
}
